var workConViewSearch_reviewState="";
var workConViewSearch_empName="";
var workConViewSearch_startDate="";
var workConViewSearch_endDate="";
var workConViewSearch_viewType="";
var userPostId="";
var viewType="";
$( document ).on( "pageshow", "#workConViewSearch", function( event ) {
	access_token=getParameterByName("access_token", getLocationUrl(event) );
	thisWorkConType = getParameterByName("workConType", getLocationUrl(event) );
	userPostId = getParameterByName("userPostId", getLocationUrl(event) );
	viewType = getParameterByName("viewType", getLocationUrl(event) );
	if(thisWorkConType == 3){
		workConType = '1';
	}else{
		workConType = thisWorkConType;
	}
	loadAreaAndPost();
	
//	if(userPostId.trim()!="S"){
//		$("#tr_viewType").hide();
//	}
	//重置
	$("#workConViewSearch_reset_search").on('click', function () {
		workConViewSearch_reviewState="";
		workConViewSearch_empName="";
		workConViewSearch_startDate="";
		workConViewSearch_endDate="";
		
		$("#workConviewSearch_reviewStateContent span").each(function(index,domEle){
			$(domEle).removeClass('redBorderSpan');
			if(index==0){
				$(domEle).addClass('redBorderSpan');
			}
		});
		$("#searchEmpName").val("");
		$("#startDate").val("");
		$("#endDate").val("");
		
	});
	//提交
	$("#workConViewSearch_submit_search").on('click', function () {
//		alert(workConSearch_searchArea+"======="+workConSearch_searchPost);
//		workConViewSearch_viewType = $("#viewType").val();
//		alert(workConViewSearch_viewType);
		viewType = getParameterByName("viewType", getLocationUrl(event) );
		workConViewSearch_empName = $("#searchEmpName").val();
		workConViewSearch_startDate = $("#startDate").val();
		workConViewSearch_endDate = $("#endDate").val();
		goTo2(rootPath+"/jsp/weixin/workConViewList.jsp?access_token="+access_token+"&workConType="+thisWorkConType
				+"&searchReviewState="+workConViewSearch_reviewState+"&searchEmpName="+workConViewSearch_empName 
				+"&searchStartDate="+workConViewSearch_startDate+"&searchEndDate="+workConViewSearch_endDate+"&viewType="+viewType+"&userPostId="+userPostId,false);
	});
});
$( document ).on( "pagecreate", "#workConViewSearch", function( event ) {
	access_token=getParameterByName("access_token", getLocationUrl(event) );
	userPostId = getParameterByName("userPostId", getLocationUrl(event) );
	viewType = getParameterByName("viewType", getLocationUrl(event) );
	//去 我的审阅列表页面
	$("#workConViewSearch_back").on('click', function () {
//		if(userPostId.trim()=="S"){
//			goTo2(rootPath+"/jsp/weixin/workConViewSList.jsp?access_token="+access_token+"&workConType="+thisWorkConType+"&userPostId="+userPostId,false);
//		}else{
			goTo2(rootPath+"/jsp/weixin/workConViewList.jsp?access_token="+access_token+"&workConType="+thisWorkConType
					+"&searchReviewState="+workConViewSearch_reviewState+"&searchEmpName="+workConViewSearch_empName 
					+"&searchStartDate="+workConViewSearch_startDate+"&searchEndDate="+workConViewSearch_endDate+"&userPostId="+userPostId+"&viewType="+viewType,false);
//		}
	});
	
});

//审批状态数据
function onClickReviewStateSpan(stateId,obj){
//	alert($("#workConSearch_areaContent span"));
	//消除所有的状态
	$("#workConviewSearch_reviewStateContent span").each(function(index,domEle){
		$(domEle).removeClass('redBorderSpan');
	});
	//给选中的赋选中状态
	$(obj).addClass('redBorderSpan');
	workConViewSearch_reviewState=stateId;
	//alert("workConViewSearch_reviewState--------"+workConViewSearch_reviewState);
}

//加载查询审阅状态数据
function loadAreaAndPost(){
	
	var arr_state=[{'flag':'1','name':'待审阅'}
				,{'flag':'2','name':'已审阅'}
				,{'flag':'3','name':'已批示'}];
	var areaCon='<span class="searchArea redBorderSpan" flag="" onclick="onClickReviewStateSpan(\'\',this)">所有</span>';
	for(var i=0;i<arr_state.length;i++){
		areaCon+='<span class="searchArea" flag="'+arr_state[i].flag+'"  onclick="onClickReviewStateSpan(\''+arr_state[i].flag+'\',this)">'+arr_state[i].name+'</span>';
	}
	$("#workConviewSearch_reviewStateContent").append(areaCon);
	
};